home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16633 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.1 KB  |  50 lines

  1. Newsgroups: comp.lang.c++,comp.lang.c,comp.os.ms-windows.programmer.misc
  2. Path: uu4news.netcom.com!friend!news
  3. From: rich@kastle.com (Richard Krehbiel)
  4. Subject: Re: fastest code
  5. Message-ID: <1996Apr11.145549.627@friend.kastle.com>
  6. Sender: news@friend.kastle.com (News)
  7. Reply-To: rich@kastle.com
  8. Organization: Kastle Development Associates
  9. X-Newsreader: Forte Free Agent 1.0.82
  10. References: <316112A2.7D37@public.sta.net.cn> <4k4ll5$fq@solutions.solon.com> <4ke5v6$17k@samba.rahul.net> <1996Apr10.110121.6784@friend.kastle.com> <4kgbmj$j3j@solutions.solon.com>
  11. Date: Thu, 11 Apr 1996 15:56:57 GMT
  12.  
  13. seebs@solutions.solon.com (Peter Seebach) wrote:
  14.  
  15. >In article <1996Apr10.110121.6784@friend.kastle.com>,
  16. >Richard Krehbiel <rich@kastle.com> wrote:
  17. >>Oliver Hellwig <hellwig@rahul.net> wrote:
  18. >>>         for (i=0; i<16; i++)
  19. >>>             prom[i] = prom[i+i];
  20.  
  21. >>>The output of the compiler left the loop but removed the 
  22. >>>assignment!
  23.  
  24. >>I suspect a proper "volatile" declaration on "prom" might have fixed
  25. >>this, i.e. if "prom" is currently declared "char prom[16]" then it
  26. >>should be declared "volatile char prom[16]".  I would not consider
  27. >>this an optimizer bug in Watcom.
  28.  
  29. >HUH?  the code as written has a clear effect, which is to shove all of
  30. >the elements of an array over one.  It certainly is an optimizer bug.
  31.  
  32. >Read the code carefully; the 2nd reference to prom[] uses a different
  33. >index into the array.  This is not a meaningless statement.
  34.  
  35. Okay, okay, that's it, I quit.  I'm not going to post any more.
  36. Further, I think I'm going to quit my programming job, buy myself a
  37. tiny shack in Montana and just build pipe bombs...
  38.  
  39. I read it as just prom[i] = prom[i], no i+i; since it was part of a
  40. device driver, the name "prom" made me think it was a hardware PROM
  41. and perhaps this little loop had some hardware effect.  In fact, I
  42. wrote exactly this loop once whose purpose was to initialize the
  43. parity bits in memory, but be non-destructive in case it was just a
  44. restart and not a power-on.
  45.  
  46. --
  47. Richard Krehbiel, Kastle Systems, Arlington VA USA
  48. rich@kastle.com (work) or richk@mnsinc.com (personal)
  49.  
  50.